﻿
using Models.Common;
using Models.Device;

using UtilsBase;
using GatewayServerService.CloudCenter;

namespace GatewayServerService.Device
{
    /// <summary>
    /// //普锐森社-	噪音noise
    /// </summary>
    public class ServiceDeviceRS4851033_ZY
    {

        //回调获获状态,为了避免误差，查状态和执行，都返回了 当前开关状态
        public void callBackUpdate(MQReqModel<object> httpReqModel)
        {
            try
            {
                ServiceCloudDeviceValueLog log = new ServiceCloudDeviceValueLog();
                ModelReceverData modelDeviceData = httpReqModel.toServerData;
                CommandLogModel commandLogModel = httpReqModel.toGatewayData;
                string result = modelDeviceData.commandResults[0].value;


                //0x01	0x03	0x02	0x02 0xC9	0x79	0x72
                //当前噪声：02C9H(十六进制) = 713=> 噪声 = 71.3dB
                string dataHex1 = result.Substring(9, 5);
                double noise = new UtilsDataTypeChange().hex16Convert10(dataHex1) * 0.1;
                log.writeSensorlog(commandLogModel.d_guid, "noise", noise.ToString(), "噪声");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }

    }

}
